<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>主页</title>
    <link rel="shortcut icon" href="/static/imgs/favicon.ico">
    <script>
        var sock = null;
        var wsuri = "ws://127.0.0.1:8080/echo";

        window.onload = function () {

            console.log("onload");

            sock = new WebSocket(wsuri);

            sock.onopen = function () {
                console.log("connected to " + wsuri);
            }

            sock.onclose = function (e) {
                console.log("connection closed (" + e.code + ")");
            }

            sock.onmessage = function (e) {
                console.log("message received: " + e.data);
            }
        };

        function send() {
            var msg = document.getElementById('message').value;
            sock.send(msg);
        };
    </script>
</head>

<body>
    {{.}}
    <form action="#" method="post" enctype="multipart/form-data">
        <input type="file" name="file" id="file">
        <input type="submit" value="上传">
    </form>

    <h1>WebSocket Echo Test</h1>
    <p>
        Message: <input id="message" type="text" value="Hello, world!">
    </p>
    <button onclick="send();">Send Message</button>

</body>

</html>